home *** CD-ROM | disk | FTP | other *** search
/ CD Exchange / CD Exchange - Volume 1.iso / games / pd / buzzbar / buzzbar.src < prev    next >
Text File  |  1993-06-19  |  17KB  |  702 lines

  1. ;
  2. ;     PROJECT BUZZ BAR
  3. ;
  4.  
  5. #reload=4       ;time till next bullet
  6. #around=4       ;num bullets in one auto fire
  7. #mythrust=4     ;5=nice and fast
  8. #bthrust=4      ;anti thrust when firing
  9. #mydrag=6
  10. #bspeed=9       ;bullet speed
  11.  
  12. #upd=7          ;number of frames for scanner and alien changes
  13. #xcntr=160+32
  14. #ycntr=100+32
  15.  
  16. #shield=128      ;shape numbers
  17. #hume=112
  18. #thrst=131
  19. #title=135
  20.  
  21. #nmetypes=48
  22.  
  23. ;
  24. ; machine code /x*x+y*y
  25. ;
  26.  
  27. Function.w distance{x1.w,y1.w,x2.w,y2.w}
  28.  UNLK a4                               ;unlink (no recursion)
  29.  SUB d2,d0:BPL xpos:NEG d0:xpos        ;d0=width
  30.  SUB d3,d1:BPL ypos:NEG d1:ypos        ;d1=height
  31.  CMP d0,d1:BEQ kludge                  ;kludge if equal
  32.  BMI ygtx:EXG d0,d1:ygtx               ;d0=greater side
  33.  TST d1:BNE yne:RTS:yne                ;if short side 0 len=other
  34.  SWAP d1:CLR d1:DIVU d0,d1:LSR#7,d1    ;look up=short/long
  35.  ADD d1,d1:SWAP d0
  36.  DIVU lvals(pc,d1.w),d0:RTS
  37.  kludge:MULU #27146,d0:SWAP d0:ADD d1,d0:RTS ;multiply by sqrt(2)
  38.  lvals:IncBin "len.inc"
  39. End Function
  40.  
  41. ;
  42. ; machine code arctan(x,y)
  43. ;
  44.  
  45. Function.w angle{x1.w,y1.w}
  46.   UNLK a4                                     ;unlink
  47.   MOVEQ#0,d2                                  ;d2=quadrant
  48.   TST d1:BPL hpos:MOVEQ#16,d2:NEG d1:hpos     ;y positive
  49.   TST d0:BPL wpos:EOR#8,d2:NEG d0:wpos        ;x positive
  50.   CMP d1,d0:BMI notsteep:BNE neq
  51.   MOVE#$2000,d1:BRA flow:neq
  52.   EOR #4,d2:EXG d1,d0:notsteep
  53.   TST d1:BNE noflow:MOVEQ#0,d1:BRA flow:noflow
  54.   EXT.ld0:SWAP d0:DIVU d1,d0:LSR#6,d0:AND#1022,d0
  55.   MOVE arc(pc,d0),d1
  56.   flow:MOVE.l oct(pc,d2),d0:EOR d0,d1:SWAP d0:ADD d1,d0:RTS
  57.   oct:Dc.w 0,0,$4000,-1,0,-1,$c000,0
  58.       Dc.w $8000,-1,$4000,0,$8000,0,$C000,-1
  59.   arc:IncBin "arc.inc"
  60. End Function
  61.  
  62. Macro ssin qsin((`1 LSR 6)&1023):End Macro
  63. Macro ccos qcos((`1 LSR 6)&1023):End Macro
  64. Macro onscreen RectsHit(`1,`2,1,1,12,12,320+32,220+32):End Macro
  65.  
  66.  
  67. NEWTYPE .nmedata
  68.   frame.w         ;shape number
  69.   numrots         ;number of roatations
  70.   thrust          ;amount of thrust 1-8
  71.   rspeed          ;max turning speed
  72.   drag            ;drag coefficient
  73.   thrusttime      ;alternate timing for thrust and fire
  74.   firepower       ;percentage liklihood of firing
  75.   points          ;score
  76.   reload          ;time to reload bullet
  77.   color           ;color on scanner
  78. End NEWTYPE
  79.  
  80. NEWTYPE .nmewave
  81.   *nme.nmedata    ;type of nme as above
  82.   start.w         ;time that first wave appears
  83.   num             ;number of waves
  84.   apart           ;time between waves
  85.   count           ;number of aliens in wave
  86.   neces           ;flag if required to finish patern
  87.   tot             ;total number
  88. End NEWTYPE
  89.  
  90. NEWTYPE .ship
  91.   x.w:y:rot:frame  ;position
  92.   xv:yv:px:py:upd  ;& speed
  93.   thcount          ;count for fire thrust alternate
  94.   fcount           ;count for
  95.   bcount
  96.   *parent.nmewave  ;points back to wave he came from
  97.   *nme.nmedata     ;points to nmetype
  98. End NEWTYPE
  99.  
  100. NEWTYPE .paterndata
  101.   pcol.w:numhumes
  102.   waves.nmewave[10]
  103. End NEWTYPE
  104.  
  105. NEWTYPE .playerdata
  106.   score.l:lives.w:shield:patern:status:xpos
  107.   ptimer:totwaves:tothumes:numhumes
  108.   nme.nmewave[10]
  109. End NEWTYPE
  110.  
  111. NEWTYPE .hume
  112.   x.w:y:rot
  113.   xv:yv:rv:frame:upd:px:py
  114. End NEWTYPE
  115.  
  116. NEWTYPE .rgb
  117.   r.w:g:b
  118. End NEWTYPE
  119.  
  120. Dim List nme.ship(50)      ;enemy
  121. Dim List bul.ship(16)      ;bullets
  122. Dim List bng.ship(50)      ;explosions
  123. Dim List fire.ship(32)     ;nme fire
  124. Dim List astro.hume(32)    ;astronauts
  125.  
  126. Dim alien.nmedata(#nmetypes) ;nme information
  127. Dim patern.paterndata(200)   ;patern information
  128. Dim player.playerdata(1)     ;2 players
  129. Dim pcols.rgb(4)
  130.  
  131. Dim a$(1000)                 ;listing
  132.  
  133. Dim qsin.q(1023),qcos(1023)   ;look up tables
  134.  
  135. me.ship\x=0,0,0,0,0,0,0
  136.  
  137. BitMap 0,320+64,220+64,3  ;doublebuffered front playfield
  138. BitMap 1,320+64,220+64,3
  139. BitMap 2,832,768,3        ;background
  140. BitMap 3,320,32,3         ;double buffered scanner
  141. BitMap 4,320,32,3
  142.  
  143. If ReadFile(0,"listing")
  144.   FileInput 0:numl=0
  145.   While NOT Eof(0)
  146.     a$(numl)=Left$(Edit$(100),38):numl+1
  147.   Wend
  148.   CloseFile 0
  149.   DefaultInput
  150. EndIf
  151.  
  152. LoadSound 0,"shoot1"
  153. LoadSound 1,"shoot2"
  154. LoadSound 2,"explo1"
  155. LoadSound 3,"explo2"
  156. LoadSound 4,"thrust1"
  157. LoadSound 5,"tankoo"
  158. LoadSound 6,"freemun"
  159. LoadSound 7,"intromusic"
  160.  
  161. LoadShapes 0,"ships.shapes"     ;8 color
  162. LoadShapes 160,"bombs.shapes"    ;2 color
  163. LoadShapes 192,"shards.shapes"   ;4 color
  164.  
  165. LoadPalette 1,"ships.iff"
  166.  
  167. LoadBitMap 2,"moon.iff"         ;back drop
  168. Use BitMap 2
  169. Scroll 0,0,320,512,512,0
  170. Scroll 0,0,832,256,0,512
  171. Use BitMap 0
  172.  
  173. Queue 0,100
  174. Queue 1,100
  175.  
  176. Gosub setuppcols
  177. Gosub setupsincos
  178. Gosub setupnme
  179. Gosub setuppaterns
  180.  
  181. BLITZ
  182. Mouse On
  183. BlitzKeys On:BitMapInput
  184. Gosub setuppalette
  185.  
  186. Slice 0,44,320,32,$fff8,3,8,8,320,320:Use Palette 1
  187. Slice 1,78,320,220,$fffa,6,8,32,320+64,832:Use Palette 1
  188.  
  189. sdb=3
  190.  
  191. .titledisplay
  192.   LoopSound 7,4:Volume 4,64
  193.   Use BitMap sdb:Cls:BitMapOutput sdb
  194.   Blit #title,160,11
  195.   Use Slice 0:Show sdb:Use Slice 1
  196.   ShowB 2,(me\x LSR 6)&511,(me\y LSR 6)&511
  197.   Use BitMap 1-db:Cls:Use BitMap db:Cls
  198.   cc=0:ci=0:l=0:db=0
  199.   Repeat
  200.     VWait
  201.     ShowF db:db=1-db:BitMapOutput db:Colour 1,0
  202.     Poke Addr BitMap(db)+4,1
  203.     Use BitMap db:Scroll 0,4,320,224,0,0,1-db:WaitBlit_
  204.     If db=0
  205.       Locate 1,27:Print a$(l):l+1:If l>numl Then l=1
  206.     EndIf
  207.     cc-1
  208.     If cc<0
  209.       cc=100:BitMapOutput sdb:Locate 1,3
  210.       Select ci
  211.         Case 0:Print "WRITTEN BY SIMON ARMSTRONG IN BLITZ 2 "
  212.         Case 1:Print " F1-1 PLAYER   F2-2 PLAYER  F10-EXIT  "
  213.         Case 2:Print "      KEYBOARD CONTROLS Z X , . /     "
  214.         Case 3:Print "      CURRENT HIGH SCORE = ",hiscore.l,"     "
  215.       End Select
  216.       ci+1:If ci=4 Then ci=0
  217.     EndIf
  218.     Poke Addr BitMap(db)+4,3
  219.     If (RawStatus($50) OR Joyx(1)=-1) Then nump=1:Gosub playgame
  220.     If (RawStatus($51) OR Joyx(1)=1) Then nump=2:Gosub playgame
  221.     If RawStatus($59) Then End
  222.   Forever
  223.  
  224. .playgame
  225.   Use Palette 1
  226.   ShowF db,32,32
  227.   ShowB 2,(me\x LSR 6)&511,(me\y LSR 6)&511
  228.   Use BitMap 1-db:Cls:Use BitMap db:Cls
  229.   player(0)\score=0,3,600,0,-1,1,0,0
  230.   player(1)\score=0,3,600,0,-1,23,0,0
  231.   If nump=1 Then player(1)\score=0,0,0,0
  232.   currp=0
  233.   While player(0)\lives>0 OR player(1)\lives>0
  234.     *p.playerdata=player(currp)
  235.     If *p\lives>0 Then Gosub newlife
  236.     If *p\score>hiscore Then hiscore=*p\score
  237.     currp=1-currp
  238.   Wend
  239.   Goto titledisplay
  240.  
  241. .newlife
  242.   Gosub initscanner:Gosub initscanner
  243.   *p\status=0
  244.   upd=0:updcount=1  ;frame update and new alien update counters
  245.   ShowF db,32,32
  246.   i=patern(*p\patern)\pcol:r=pcols(i)\r:g=pcols(i)\g:b=pcols(i)\b
  247.   Gosub planetcolor:Use Palette 1
  248.   Use BitMap db:Cls:BitMapOutput db
  249.   Locate 20,15:Colour 1:Print "PLAYER ",currp+1
  250.   Gosub oldaliens
  251.   VWait 100:Cls
  252.   LoopSound 4,4:Volume 4,0
  253.  
  254. .mainloop
  255.   Repeat
  256.     If RawStatus($45) Then End
  257.     VWait
  258.     ShowF db,32,32
  259.     ShowB 2,(me\x LSR 6)&511,(me\y LSR 6)&511
  260.     If *p\totwaves=0 AND numexp=0 Then Gosub newpatern
  261.     Gosub newaliens
  262.     If upd=0 Then Gosub doscanner
  263.     db=1-db
  264.     Use BitMap db
  265.     UnQueue db
  266.     Gosub drawnme
  267.     Gosub drawfire
  268.     Gosub astromen
  269.     If *p\status=0 Then Gosub moveship
  270.     Gosub drawbullets
  271.     Gosub moveexplosions
  272.     upd+1:If upd>#upd Then upd=0
  273.     *p\ptimer+1
  274.     If (*p\ptimer AND 7)=0 Then ct3+1:If ct3=3 Then ct3=0
  275.   Until *p\status=-1 AND numexp=0
  276.   ClearList nme()
  277.   ClearList bul()
  278.   ClearList fire()
  279.   ClearList astro()
  280.   *p\lives-1
  281.   Volume 4,0
  282.   Return
  283.  
  284. .oldaliens
  285.   USEPATH *p\nme[i]
  286.   i=0
  287.   While \nme AND i<10
  288.     j=0:While j<\tot:Gosub addalien:j+1:Wend
  289.     i+1
  290.   Wend
  291.   Gosub addhumes
  292.   Return
  293.  
  294. .addhumes
  295.   i=0
  296.   While i<*p\tothumes
  297.     AddItem astro()
  298.     astro()\x=Rnd($ffff),Rnd($ffff),0
  299.     astro()\xv=Rnd(200)-100,Rnd(200)-100,Rnd(16384)-8192,0
  300.     astro()\upd=updcount
  301.     updcount+1:If updcount>#upd Then updcount=1
  302.     i+1
  303.   Wend
  304.   Return
  305.  
  306. .newaliens
  307.   USEPATH *p\nme[i]
  308.   i=0
  309.   While \nme AND i<10
  310.     If *p\ptimer=\start   ;time for a new wave
  311.       For j=1 To \count
  312.         Gosub addalien
  313.         \tot+1
  314.       Next
  315.       If \num>0 Then \num-1
  316.       If \num<>0 Then \start+\apart Else \start=0
  317.     EndIf
  318.     i+1
  319.   Wend
  320.   Return
  321.  
  322. .addalien
  323.   AddItem nme()
  324.   nme()\x=me\x+Rnd($c000)+$2000
  325.   nme()\y=me\y+Rnd($c000)+$2000
  326.   nme()\rot=Rnd(65535),0,0,0,0,0,0,0,0
  327.   nme()\upd=updcount
  328.   nme()\parent=*p\nme[i]
  329.   nme()\nme=\nme
  330.   updcount+1:If updcount>#upd Then updcount=1
  331.   nme()\th